<?php
class model__action_model extends database_mysql
{
    public function __construct()
    {
        parent::__construct();
        
    }
    
    public function md_cm_get_list_com($app){
        $sql = "
                SELECT *
                FROM
                ".prefix."categories
                WHERE
                ".prefix."categories.Define = 'com' AND
                ".prefix."categories.App = '$app'
        ";
        $rs = parent::mysql_fetch_all_rows($sql);
        return $rs;
    }
    
    public function md_cm_get_list_action(){
        $sql = "
                SELECT *
                FROM
                ".prefix."actions
                WHERE
                ".prefix."actions.`Status` = 'true'
        ";
        $rs = parent::mysql_fetch_all_rows($sql);
        return $rs;
    }
    
    public function md_cm_get_list_ation_com($id){
        $sql = "
                SELECT
                ".prefix."actions.ActName
                FROM
                ".prefix."com_act
                INNER JOIN ".prefix."actions ON ".prefix."actions.ID = ".prefix."com_act.ActID
                WHERE
                ".prefix."com_act.ComID = $id

        ";
        $rs = parent::mysql_fetch_all_rows($sql);
        return $rs;
    }
    
    public function md_cm_get_com_from_id($id, $app){
        $sql = "
                SELECT
                ".prefix."categories.Com
                FROM
                ".prefix."categories
                WHERE
                ".prefix."categories.App = '$app' AND
                ".prefix."categories.ID = $id AND
                ".prefix."categories.Define = 'com'

        ";
        $rs = parent::mysql_fetch_one_rows($sql);
        return $rs;
    }
    
    public function md_cm_get_act_from_id($id){
        $sql = "
                SELECT
                ".prefix."actions.ActName
                FROM
                ".prefix."actions
                WHERE
                ".prefix."actions.ID = $id

        ";
        $rs = parent::mysql_fetch_one_rows($sql);
        return $rs;
    }
    
    public function md_cm_insert_action($data){
        parent::mysql_insert_array(prefix . 'com_act',$data);
    }
    
    public function model_action_check_action($action,$com){
        $sql = "
                SELECT
                ".prefix."com_act.ComID
                FROM
                ".prefix."com_act
                WHERE
                ".prefix."com_act.ComID = $com AND
                ".prefix."com_act.ActID = $action

        ";
        $rs = parent::mysql_fetch_one_rows($sql);
        return $rs;
    }
   
}
